Completely Automated Public Turing test to tell Computers and Humans Apart code (CAPTCHA), commonly referred to as CAPTCHA code, is a completely automated public procedure that can be used to tell whether a user is a machine or a person. To prevent a malicious user from using a machine to automatically perform operations such as login, information release and download, when the user performs a related operation, a server delivers a CAPTCHA image to a terminal of the user, and requests the user to enter a CAPTCHA code included in the CAPTCHA image to determine that the user that performs the operation is a person rather than a machine. Therefore, before delivering the CAPTCHA image to the terminal that is used by the user, the server needs to generate the CAPTCHA image first.
To avoid machine recognition, when the CAPTCHA image is generated, an initial image including the CAPTCHA code is generated first, and then noise scrambling is performed on the initial image to obtain the CAPTCHA image. Specifically, any one of the following ways may be included.
A first way to generate a CAPTCHA image may include the steps to: Obtain the initial image including the CAPTCHA code; and generate noise points in a whole image region of the initial image to obtain the CAPTCHA image.
A second way to generate a CAPTCHA image may include the steps: Obtain the initial image including the CAPTCHA code; and generate noise points on the CAPTCHA code of the initial image to obtain the CAPTCHA image.
Generally, noise points on a whole CAPTCHA image can be well filtered out by means of a median filtering method. Therefore, when a whole image region of the CAPTCHA image includes the noise points, a machine can filter out the noise points on the CAPTCHA image by means of the median filtering method, and can recognize a CAPTCHA code in the CAPTCHA image. In addition, an expansion algorithm in an image processing field has a good adhesion effect, so that the machine can easily filter out, by means of the expansion algorithm, the noise points that are generated on the CAPTCHA code, to recognize the CAPTCHA code in the CAPTCHA image. Based on the above, the CAPTCHA image that is generated by means of the above two manners has a high risk of being cracked by the machine, and has a poor crack-proof capability.